import socket
import threading


def funcA(new_tcp_socket,address):
    while True:
        result = new_tcp_socket.recv(1024)
        print(f"{address}用户输入{result.decode()}")

        if not result:
            print("对方已下线")
            break
        new_tcp_socket.send(result)

if __name__ == '__main__':
    tcp_socket = socket.socket()

    tcp_socket.bind(('',9999))

    tcp_socket.listen(128)

    while True:
        new_tcp_socket, address = tcp_socket.accept()
        threading.Thread(target=funcA,args=(new_tcp_socket,address)).start()
